<?php
namespace app\website\model;

use app\BaseModel;
use think\facade\Db;

class StarChoose extends BaseModel
{
    //定义表名
    protected $name = 'longbing_card_web_star_choose';


    /**
     *
     * 1:地区 2：艺人分类 3：职业分类 4：年龄
     */
    /**
     * @author chenniang
     * @DataTime: 2020-12-08 10:51
     * @功能说明:列表
     */
    public function chooseList($dis,$page){

        $data = $this->where($dis)->order('top desc,id desc')->paginate($page)->toArray();

        return $data;

    }

    /**
     * @author chenniang
     * @DataTime: 2020-10-09 17:05
     * @功能说明:配置详情
     */
    public function chooseInfo($dis){

        $data = $this->where($dis)->find();

        return !empty($data)? $data->toArray():[];

    }


    /**
     * @author chenniang
     * @DataTime: 2020-09-29 11:04
     * @功能说明:配置添加
     */
    public function chooseAdd($data){

        $data['create_time'] = time();

        $data['update_time'] = time();

        $res = $this->insert($data);

        return $res;

    }



    /**
     * @author chenniang
     * @DataTime: 2020-09-29 11:05
     * @功能说明:配置编辑
     */
    public function chooseUpdate($dis,$data){

        $data['update_time'] = time();

        $res = $this->where($dis)->update($data);

        return $res;

    }


    /**
     * @author chenniang
     * @DataTime: 2020-12-25 14:36
     * @功能说明:明星的各项数据
     */
    public function chooseData($star_id,$type){

        $dis = [

            'b.id'     => $star_id,

            'b.type'   => $type,

            'a.type'   => $type,

            'a.status' => 1,
        ];

        $data = $this->alias('a')
                ->join('longbing_card_web_star_connect b','a.id = b.connect_id')
                ->where($dis)
                ->field('a.title')
                ->group('a.id')
                ->order('a.top desc,a.id desc')
                ->select()
                ->toArray();

        return $data;

    }














}